package com.inossem.utils.encryption;

import android.util.Base64;

import java.io.UnsupportedEncodingException;

/**
 * Created by leij on 2017/6/30.
 */

public class Base64Utils {

    public static String encode(String message) {
        String result = "";
        result = Base64.encodeToString(message.getBytes(), Base64.NO_WRAP);
//        return result.replaceAll("[\\s*\t\n\r]", "");
        return result;
    }

    public static String decode(String code) {
        String result = "";
        try {
            result = new String(Base64.decode(code, Base64.DEFAULT), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return result;
    }

}
